const MovieService = require("../service/MovieService");

const MovieController = {
  getMovieList: async (req, res) => {
    try {
      const listData = await MovieService.getMovieList(req.query);
      res.send({
        code: 200,
        message: "getMovieList",
        data: listData,
      });
    } catch (err) {
      res.status(err.status).send({
        code: err.status,
        message: err.message,
        data: err.data || null,
      });
    }
  },
  getDramaList: async (req, res) => {
    try {
      const listData = await MovieService.getDramaList(req.query);
      res.send({
        code: 200,
        message: "getDramaList",
        data: listData,
      });
    } catch (err) {
      res.status(err.status).send({
        code: err.status,
        message: err.message,
        data: err.data || null,
      });
    }
  },
  getMediaDetail: async (req, res) => {
    try {
      const detailData = await MovieService.getMediaDetail(req.params.id);
      res.send({
        code: 200,
        message: "getMediaDetail",
        data: detailData,
      });
    } catch (err) {
      res.status(err.status).send({
        code: err.status,
        message: err.message,
        data: err.data || null,
      });
    }
  },
};

module.exports = MovieController;
